﻿using CPPEI.Coolzon.UI;
using CPPEI.Coolzon.UI.DataPartLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CPPEI.Coolzon.BrowserApp.MainViewControl
{
    /// <summary>
    /// MainViewHeader.xaml 的交互逻辑
    /// </summary>
    public partial class Header : UserControl
    {
        public Header()
        {
            InitializeComponent();
            tbMessage.Text = "欢迎您-" + UIContext.Current.UserName;
        }
        /// <summary>
        /// 用户注销
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LogOut_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            UI.View viewLogOut = new MessageView("确定注销吗?");
            viewLogOut.Close += (view, isCancel) =>
            {
                if (!isCancel)
                {
                    NavigationService.GetNavigationService(this).Navigate(new Uri(CZEnvironment.HostUrl + "Logout.aspx", UriKind.Absolute));
                }
            };
            UIContext.Current.RootViewContainer.PopView("提示", viewLogOut);
        }

        /// <summary>
        /// 系统帮助
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Help_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            NavigationService.GetNavigationService(this).Navigate(new Uri(CZEnvironment.HostUrl + "Help.aspx", UriKind.Absolute));
        }
        /// <summary>
        /// 退出系统
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Exit_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            UI.View viewExit = new MessageView("确定退出吗?");
            viewExit.Close += (view, isCancel) =>
            {
                if (!isCancel)
                {
                    NavigationService.GetNavigationService(this).Navigate(new Uri(CZEnvironment.HostUrl + "Exit.aspx", UriKind.Absolute));
                }
            };
            UIContext.Current.RootViewContainer.PopView("提示", viewExit);
        }
    }
}
